// const fn = (name: string, age: number): string => {
//   return name + age
// }
// console.log(fn('张三', 18));
//函数的可选参数
// const fn = (name: string, age?: number): string => {
//   return name + age
// }
// console.log(fn('张三'));
//函数参数的默认值
// const fn = (name: string, age: number = 17): string => {
//   return name + age
// }
// console.log(fn('张三'));
//接口定义函数
interface Add {
  (num: number, num2: number): number
}
const fn: Add = (num: number, num2: number): number => {
  return num + num2
}
console.log(fn(5, 5));
interface info {
  name: string;
  age: number;
}
function getUserInfo(user: info): info {
  return user
}
// getUserInfo()
//定义剩余参数
const fn2 = (array: number[], ...items: any[]): any[] => {
  console.log(array, items);
  return items
}
let a: number[] = [1, 2, 3]
fn1(a, '4', '5', '6')
//函数重载
function fun(name: string): void
function fun(name: string, age: number): void
function fun(name: any, age?: any): void {
  console.log(name);
  console.log(age);

}
fun('周杰伦')
fun('你好啊', 7)